home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9765 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  899 b 

  1. Path: d1o2.telia.com!usenet
  2. From: <>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: big problem with a very small program:please help me!
  5. Date: 12 Mar 1996 10:40:08 GMT
  6. Organization: Telia Internet Services
  7. Message-ID: <4i3ka8$m3n@d1o2.telia.com>
  8. NNTP-Posting-Host: t6o1p3.telia.com
  9.  
  10. escali_m@worldnet.net (Marc Escalier) skriver:
  11. > #include <stdio.h>
  12. > #include <math.h>
  13. > main()
  14. > {
  15. > float i;
  16. > i=5.25;
  17. > printf("i is real:l%f\n",i);            /* display 5.25000000000000... ok! */
  18. > printf("i is integer%d\n",i);        /* display 0  what does that mean
  19. > ?!?*/
  20. > return(0);
  21. > }
  22. > thanx for any help.
  23. > please answer by email because i don't read often comp.lang.c.
  24.  
  25. You must do a cast like this:
  26.    printf( "i is integer %d\n", ( int ) i );
  27.  
  28. This is because the printf function parameter %d expects a variable value
  29. formatted as an integer and not as a float, which i is.
  30.  
  31. Try this and good luck!
  32.  
  33. /Erik
  34.  
  35.  
  36.